<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Vue页面结构</title>
    <script src="./lib/vue-2.4.0.js"></script>
</head>
<body>
    <div id="app">
            <c1></c1>
            <c2></c2>
    </div>
</body>
<script>
    var Bus = new Vue();
    Vue.component('c1',{
        template:'<div>{{msg}}</div>',
        data: () => ({
            msg: 'Hello World!'
        }),
        created() {
            Bus.$on('setMsg', content => {
                this.msg = content;
            });
        }
    });
    Vue.component('c2',{
        template: '<button @click="sendEvent">Say Hi</button>',
        methods: {
            sendEvent() {
                Bus.$emit('setMsg', 'Hi Vue!');
            }
        }
    });
    var app= new Vue({
        el:'#app'
    })
</script>
</html>